﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Collections.Specialized;

namespace _1
{
    class Renamer
    {
        //private string path;
        //private DateTime date;
        public NameValueCollection NVClist = new NameValueCollection();

        //public string Path
        //{
        //    get
        //    {
        //        return path;
        //    }

        //    set
        //    {
        //        path = value;
        //    }
        //}
        //public DateTime Date
        //{
        //    get
        //    {
        //        return date;
        //    }

        //    set
        //    {
        //        date = value;
        //    }
        //}

        public void Raname(string p, DateTime d)
        {
            if (Directory.Exists(p))
            {
                DirectoryInfo directory = new DirectoryInfo(p);
                //NameValueCollection list = new NameValueCollection();
                FileInfo[] files = directory.GetFiles();
                foreach (FileInfo file in files)
                {
                    if (file.LastWriteTime < d)
                    {
                        NVClist.Add(file.Name, "удалён");
                        File.Delete(file.FullName);
                    }
                    else
                    {
                        //File.Move(file.FullName, file.FullName);
                        file.MoveTo(file.Name+d.ToShortDateString());//file.Name+d.ToShortDateString());
                        NVClist.Add(file.Name, "переименован");
                    }
                }
            }
        }
    }
}
